<!-- <script lang="js">
  
  

</script> -->
<template>
    <div id="manage">
        <!-- 搜索框 -->
        <el-form :inline="true" :model="condition" class="demo-form-inline">
            <!-- 原病理号 -->
            <el-form-item label="原病理号：">
                <el-input v-model="condition.case_no" placeholder="" clearable />
            </el-form-item>
    
            <!-- 患者姓名 -->
            <el-form-item label="患者姓名：">
                <el-input v-model="condition.name" placeholder="" clearable />
            </el-form-item>
    
            <!-- 状态 -->
            <el-form-item label="状态：">
                <el-select v-model="condition.status" placeholder=" " clearable>
                    <el-option label="待诊断" value="0" />
                    <el-option label="诊断中" value="1" />
                    <el-option label="已诊断" value="2" />
                    <el-option label="已审核" value="3" />
                    <el-option label="已退回" value="4" />
                    <el-option label="未提交" value="8" />
                </el-select>
            </el-form-item>
    
            <!-- 送检时间 -->
            <el-form-item label="送检时间：">
                <el-date-picker v-model="condition.start" type="date" placeholder="开始日期" clearable />
                &puncsp; - &puncsp;
                <el-date-picker v-model="condition.end" type="date" placeholder="结束日期" clearable />
            </el-form-item>
    
        </el-form>
    
        <!-- 按钮 -->
        <el-form>
    
            <el-button style="float: left;" @click="refresh"> <el-icon>
                    <RefreshRight />
                </el-icon> 刷新 </el-button>
            <el-button style="float: right;" @click="reset"> <el-icon>
                    <Refresh />
                </el-icon> 重置 </el-button>
            <el-button style="float: right;" @click="condition.page=1;manage.emrcaselist(manage);"> <el-icon>
                    <Search />
                </el-icon> 查询 </el-button>
    
        </el-form>
    
        <!-- 表格位置 -->
        <el-table :data="manage.list" style="width: 100%" border stripe=true>
            <el-table-column type="selection" width="55">
            </el-table-column>
    
            <el-table-column sortable prop="status" label="状态" :formatter="statusFormat" width="180" />
            <el-table-column sortable prop="case_no" label="原病理号" width="180" />
            <el-table-column prop="name" label="患者姓名" width="180" />
            <el-table-column prop="sex" label="性别" :formatter="sexFormat" />
            <el-table-column prop="age" label="年龄" />
            <el-table-column sortable prop="send_date" label="送检日期" />
            <el-table-column show-overflow-tooltip prop="send_hospital" label="送检医院" />
            <el-table-column prop="send_doctor" label="送检医生" />
            <el-table-column sortable prop="pathology_type" label="病理分类" :formatter="ptypeFormat" />
            <el-table-column prop="expert_name" label="会诊专家" />
            <el-table-column show-overflow-tooltip prop="expert_diagnosis" label="诊断意见" />
            <el-table-column sortable prop="expert_date" label="报告完成时间" />
            <el-table-column prop="case_fee" label="会诊费用" />
            <el-table-column sortable prop="update_date" label="更新时间" />
            <el-table-column label="操作" :formatter="btnFormat">
                <template v-slot="scope">
                    <el-button @click="skip(scope.row.id,1)" style="width: 60px;"> <el-icon>
                            <Search />
                        </el-icon> 查询 </el-button>
                    <br>
                    <el-button @click="skip(scope.row.id,2)" v-if='scope.row.status == 1||scope.row.status == 0'
                        type="primary" plain style="width: 60px;">处理</el-button>
                </template>
            </el-table-column>
    
        </el-table>
    
        <div class="demo-pagination-block" style="width:100% ;margin: 0 auto; padding-left: 30%;">
            <el-pagination v-model:current-page="manage.condition.page" v-model:page-size="manage.condition.rows"
                :page-sizes="[5, 10, 15, 20]" :small="manage.condition.small" :disabled="manage.condition.disabled"
                :background="manage.condition.background" layout="total, sizes, prev, pager, next, jumper"
                :total="manage.condition.total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
        </div>
    
    </div>
</template>

<script setup>
	//导入 manage 的 store
	import manageStore from '@/store/modules/manage';
	import { getCurrentInstance } from 'vue';

	const manage = manageStore();
	manage.emrcaselist(manage);
	const condition = manage.condition;
	condition.expert_id = '';
	// 表格数据
	// const tableData = manage.list ;
	// console.log("9999"+tableData) ;

	watch(manage.list, (old, yang) => {
		console.log(old);
		console.log(yang);
	})

	//各种状态 形显具生
	//状态的 形式
	// const {proxy} = getCurrentInstance() ;
	// const {deal_status} = proxy.useDict("deal_status") ;
	// console.log(deal_status) ;
	function statusFormat(row, column) {
		if (row.status == 0) {
			return "待诊断"
		} else if (row.status == 1) {
			return "诊断中"
		} else if (row.status == 2) {
			return "已诊断"
		} else if (row.status == 3) {
			return "已审核"
		} else if (row.status == 4) {
			return "已退回"
		} else if (row.status == 8) {
			return "未提交"
		} else {
			return "其他"
		}
	}

	//病理分类 形式
	function ptypeFormat(row, column) {
		if (row.pathology_type == 1) {
			return "常规"
		} else if (row.pathology_type == 2) {
			return "冰冻"
		} else if (row.pathology_type == 3) {
			return "细胞"
		} else if (row.pathology_type == 4) {
			return "组织"
		} else {
			return "其他"
		}
	}

	//性别 形式
	function sexFormat(row, column) {
		if (row.sex == 1) {
			return "男"
		} else if (row.sex == 2) {
			return "女"
		} else {
			return "无"
		}
	}

	//按钮 形式

	const isEdit = ref(false);
	function btnFormat(row, column) {
		if (row.status == 1) {
			return isEdit.value = true;
		}
	}

	//分页
	const handleSizeChange = (value) => {
		console.log(`${value} items per page`);
		manage.emrcaselist(manage);
	}
	const handleCurrentChange = (value) => {
		console.log(`current page: ${value}`);
		manage.emrcaselist(manage);
	}

	//按钮实现
	//刷新
	const refresh = () => {
		document.location.reload();
	}
	//重置
	const reset = () => {
		document.location.reload();
	}
	//跳转事件 查询 处理
	const $router = useRouter();
	const skip = (id, status) => {
		console.log("id:" + id + ",status:" + status);
		localStorage.setItem('emrCaseId', id);
		localStorage.setItem('emrCaseStatus', status);
		$router.push('/consultation/details/clinic');
	}

  //处理按钮的显示




</script>

<style>
#manage {
    padding: 3%;
}

.demo-form-inline {
    width: 100%;
}

.demo-form-inline .el-input {
    --el-input-width: 150px;
}

.demo-pagination-block+.demo-pagination-block {
    margin-top: 10px;
}

.demo-pagination-block .demonstration {
    margin-bottom: 16px;
}
</style>